package com.yingxin.yxerp.module.inform.controller;

import com.yingxin.yxerp.module.inform.entity.UserNotice;
import com.yingxin.yxerp.module.inform.entity.builder.UserNoticeBuilder;
import com.yingxin.yxerp.module.inform.service.IUserNoticeService;
import com.yingxin.yxerp.module.inform.vo.req.UserNoticeCreateVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 通知公告用户信息 前端控制器
 * @author matongtong
 * @since 2023-12-08
 */

@Api(tags = "通知公告用户信息")
@RestController
@RequestMapping("/inform/user/notice")
public class UserNoticeController {

    @Autowired
    private IUserNoticeService userNoticeService;

    @ApiOperation(value = "根据id查询")
    @GetMapping("/{id}")
    public UserNotice get(@PathVariable("id") String id) {
        UserNotice entity = userNoticeService.mapper().getVo(id);
        return entity;
    }

    @ApiOperation(value = "新增")
    @PostMapping
    public void create(@RequestBody UserNoticeCreateVo createVo) {
        UserNotice userNotice = UserNoticeBuilder.build( createVo );
        userNoticeService.create(userNotice);
    }

    @ApiOperation(value = "全部已读")
    @GetMapping("/all/read")
    public void allRead() {
        userNoticeService.allRead();
    }

}
